/*$(function(){
	$('tbody tr').mouseover(function () {
		$(this).addClass('toggle');
	});
	$('tbody tr').mouseout(function () {
		$(this).removeClass('toggle');
	});
//	$('td').mouseover(function() { alert('dsdsd'); });
});*/

/*************************************************************
	MyTools
**************************************************************/
(function($){
myTools = {
	
	/****************************
	 * возвращает параметры обьекта 
	*****************************/
	myElementParams : function(elem) {
		var elem = ( typeof(elem) == "object" ) ? ( typeof(elem.jquery) == "undefined" ? elem : elem.get(0) ) : $(elem)[0];
		var left = 0;
		var top = 0;
		var width = elem.offsetWidth;
		var height = elem.offsetHeight;
		if (elem.offsetParent) {
			do {
					left += elem.offsetLeft;
					top += elem.offsetTop;
			} while (elem = elem.offsetParent);
		};
		if(self.innerWidth!=undefined) { A= [self.innerWidth,self.innerHeight];	}
		else {
			var D= document.documentElement;
			if(D) {A= [D.clientWidth,D.clientHeight];}
		}
		return {
			d: [width, height],
			p: [left, top]
		};
	},
	
	/***********************************
	 * дампер свойств\методов обьекта + кол-во
	 * @param {} obj
	 * @param {} obj_name
	 * @return {}
	************************************/
	objDump : function(obj, obj_name, ret) {
		var len = '';
		var result = '';
		for (var i in obj) {
			result += obj_name + '.' + i + ' = ' + obj[i] + '\n';
			len = ++len;
		}
		if (ret == true) {return result;}
		else {return len}
	}
}
})(jQuery);






/********************************************************
	Присутствие
*********************************************************/
$(function() {
	var which = $(".mP a");
	yTest = false;
	which.hover(
		function () { $(this).css('cursor','pointer'); },
		function () {}
	);
	which.click(function(){
		yTest = true;
		var obj = $(this);
		var cid = obj.attr('id');
		var Pid = obj.parent().parent().attr('id');
		var oldClass = obj.attr('class')
		var oldText = obj.text();

		if(boxerInplace2.inited == true) {
			boxerInplace2.hide();
			obj.removeAttr('class').addClass(oldClass);
		}
		/*var text = '<div class="owBlock" style=""><ol style="list-style: none;">'
			+ '<li class="mpl1" title="mpOut"><a href=""  class="mpOut" title="неявка">неявка</a></li>'
			+ '<li class="mpl2" title="mpDelay"><a href="#" class="mpDelay" title="опоздание">опоздание</a></li>'
			+ '<li class="mpl3" title="mpIll"><a href="" class="mpIll" title="болезнь">болезнь</a></li>'
			+ '<li class="mpl4" title="mpPass"><a href="" class="mpPass" title="пропуск">пропуск</a></li>'
			+ '<li class="mpl5" title="mpNone"><a href="" class="mpNone" title="">отмена</a></li>'
			+ '</div>';*/
		var text = '<div class="owBlock" style=""><ol style="list-style: none;">';
		for(var i in logEntryStatus) {
			text += '<li class="mpl1" title="'+ logEntryStatus[i][0] +'"><a href=""  class="'+ logEntryStatus[i][0] +'" title="'+ logEntryStatus[i][2] +'">'+ logEntryStatus[i][1] +'</a></li>';
		}
		text += '</div>';
		boxerInplace2.show(obj , text , {delay : false ,className : "confirm2", xId:'boxerInplace2'});
		
		var linkObj = $('.owBlock li a');
		linkObj.hover(function(){
			if (yTest === true ) {
				var xClass = $(this).parent().attr('title');
				var xText = $(this).attr('title');
				obj.removeAttr('class').addClass(xClass);
				obj.empty().html(xText)
				
				/* эвент на клик выбора */
				$(this).click(function(){
					if (oldText == xText) {
						obj.removeAttr('class').addClass(oldClass);
						obj.html(oldText);
						boxerInplace2.hide();
						return false;
					} else {
					obj.empty().removeAttr('class').addClass('ajaxWait');
					if( yTest == true) {
					yTest = false;
					myAjax.send({
						url: ajaxUrl,
						pid: Pid,
						type : 'presence',
						value : xText,
						succcess : function(){
							obj.removeAttr('class').addClass(xClass).html(xText);
						},
						error : function(){
							obj.removeAttr('class').addClass(oldClass);
							boxerInplace2.show(obj, '<div style="padding:10px; width:160px; text-align:center">Произошел сбой.<br />Попробуйте ещё раз</div>',
							{delay : 1500 ,className : "confirm2", xId:'boxerInplace2'});
						}
					});
					}
					boxerInplace2.hide();
					return false;
					}
				})
				/*overlay.click(function () {
					obj.removeAttr('class').addClass(oldClass);
					boxerInplace.hide();
					overlay.remove();
				});*/
			}
		},
		function(){
			if (yTest === true) {
				obj.removeAttr('class').addClass(oldClass);
				obj.html(oldText);
			}
		});
	});
});





/******************************************************
	Коментарии
*******************************************************/
$(function() {
	var which = $(".mC div span");

	which.click(function(){
		if(boxerInplace.inited == true) {
				boxerInplace.hide();
			}
		if (myComment.active != true) {
			var zArea = myComment.show($(this));
			boxerHelper.show($(this), 'для сохранения нажмите "Enter", или просто кликните за пределами формы, нажатие "Esc" отменит изменения',
				{delay: false ,className : "helper", xId:'helper', xTop : 95});
		}
		zArea.blur(function(){
//			$('.owButSubmit').click(function(){myComment.hideOk();});
			boxerHelper.hide();
			myComment.hide();
		});
		zArea.keypress(function (e) {
			if (e.keyCode == 13){ myComment.hide(); boxerHelper.hide(); }
			else if (e.keyCode == 27) {
				myComment.zEscFlag = true;
				myComment.hide();
				boxerHelper.hide();
			}
		});

	});
	var destr = $(".mC div a");
	destr.click(function(){
			myComment.destroy($(this));
			return false;
	});
});

/*
 * все функции стартуют от контролов событий прописанных отдельно (выше)
 * предпологается, что из этого должен получиться обработчик
 * т.к. контролы то разные а действия одни
 */
(function($){
myComment = {
	options : {
		buttons : []
		,zActive : false
		,zTextDefault : 'нажмите что бы добавить коментарий'
	},
	
	show: function (element) {
		var zThis = element;
		this.zElement = element;
		this.pid = element.parent().parent().parent().attr('id');
		this.zTextOld = zThis.html();
		this.zOldType = zThis.parent().attr('class');
		this.zElement.parent().removeClass(this.zOldType);

		var zAreaText = '';
		if (this.zOldType == 'mcText') {zAreaText = this.zTextOld;}
		var zHtml = '<div class="zDiv" style="z-index:1000;"><textarea style="font-size:12px; width:210px; height:65px;" class="zText">'
				+ zAreaText + '</textarea>'
				+'</div>';
		
		if (this.active != true) {
//		$('<div style="position:absolute; top:0; left:0; width:100%; height:100%; z-index:100;" id="overlay"></div>').appendTo($("body"));
			zThis.empty().html(zHtml);
			this.zElement.parent().find('a').hide();
			var zArea = zThis.find('textarea');
			zArea.focus();
		
			this.active = true;
			return zArea;
		}
	},
	/*
	 * "прячет" textarea сохраняя результат
	 * не имеет смысла без show()
	 */
	hide: function() {
		this.xMark = true;
		this.zNewText = $('.zDiv textarea').val();
		if(this.zNewText == '') {
			this.zElement.parent().addClass('mcNone');
			zHtmlOut = this.options.zTextDefault;
			this.zElement.parent().find('a').hide();
		}
		else if(this.zNewText != '' && this.zEscFlag == true && this.zOldType == 'mcText') {
//			if (this.zOldType != 'mcNone') {this.zElement.parent().addClass('mcText');}
			this.zElement.parent().addClass('mcText');
			zHtmlOut = this.zTextOld;
		}
		else {
			zHtmlOut = ''+ this.zNewText;
			this.value = zHtmlOut;
			this.zElement.parent().addClass('mcText');
			this.zElement.parent().find('a').show();
		}
		if (this.value) {
			if(this.xMark == true) {
			this.xMark = false;
			myAjax.send({
				pid: this.pid,
				type : 'comment',
				value : this.value,
				succcess : function(){
//					obj.removeAttr('class').addClass(xClass).html(xText);
				},
				error : function(){
//					obj.removeAttr('class').addClass(oldClass);
					boxerInplace2.show(obj, '<div style="padding:10px; width:160px; text-align:center">Произошел сбой.<br />Попробуйте ещё раз</div>',
					{delay : 1500 ,className : "confirm2", xId:'boxerInplace2'});
				}
			});
			}
		}
		this.zElement.empty().html(zHtmlOut);
		
		this.zEscFlag = false;
		this.active = false;
	},
	/*
	 * удаляет текст комментария и сбрасывает на дефолты
	 */
	destroy : function(element) {
		this.value = 'delet';
		element.parent().removeClass().addClass('mcNone');
		zHtmlOut = this.options.zTextDefault;
		element.parent().find('span').empty().html(zHtmlOut);
		element.hide();
	}
};
})(jQuery);




/*****************************************************************
 Marks
******************************************************************/
$(function() {
	var arrMarks = ['1-', '1', '1+', '2-', '2', '2+', '3-', '3', '3+', '4-', '4', '4+', '5-', '5', '5+'];
	
	var which = $('a.mmPlace');
	var xTest = false;
	
	if (!$.browser.msie) {
		which.hover(
			function () { $(this).addClass('mmHover');},
			function () { $(this).removeClass('mmHover'); }
		);
	}
	
	/* первый клик */
	which.bind("click" , function() {
		var obj = $(this);
		var cid = obj.attr('id');
		var Pid = obj.parent().parent().attr('id');
		var parentClass = obj.parent().parent().attr('class');
		var oldClass = obj.attr('class')
		var oldMark = obj.html();
		xTest = true;

		if(boxerInplace2.inited == true) {
			boxerInplace2.hide();
			obj.removeAttr('class').addClass(oldClass);
		}
		if (parentClass == 'mH') {
			var text = '<div class="owBlock" style=""><ol style="list-style: none;">'
				+ '<li class="mml5" title="mmFive"><a href="" class="mmHide" title="5-">5-</a><a href="" class="mpNone" title="5">5</a><a href="" class="mmHide" title="5+">5+</a></li>'
				+ '<li class="mml4" title="mmFor"><a href="" class="mmHide" title="4-">4-</a><a href="" class="mpPass" title="4">4</a><a href="" class="mmHide" title="4+">4+</a></li>'
				+ '<li class="mml3" title="mmThree"><a href="" class="mmHide" title="3-">3-</a><a href="" class="mpIll" title="3">3</a><a href="" class="mmHide" title="3+">3+</a></li>'
				+ '<li class="mml2" title="mmTwo"><a href="" class="mmHide" title="2-">2-</a><a href="" class="mm2" title="2">2</a><a href="" class="mmHide" title="2+">2+</a></li>'
				+ '<li class="mml1" title="mmOne"><a href="" class="mmHide" title="1-">1-</a><a href="" class="mm1" title="1">1</a><a href="" class="mmHide" title="1+">1+</a></li>'
				+ '</ol><div class="mmDelet"><a href="">удалить</a></div>'
				+ '</div>';
		} else if (parentClass == 'mZ'){
			var text = '<div class="owBlock" style=""><ol style="list-style: none;">'
				+ '<li class="mmExam true" title="mmExamTrue"><a href="#" title="зт">зачет</a></li>'
				+ '<li class="mmExam false" title="mmExamFalse"><a href="#" title="нзт">не зачет</a></li>'
				+ '</ol><div class="mmDelet"><a href="">удалить</a></div></div>';
		}
		boxerInplace2.show(obj , text , {delay : false ,className : "confirm2", xId:'boxerInplace3'});
			
		var linkObj2 = $('.owBlock li');
		/* ховер для видимости оценок */
		if( xTest === true && parentClass == 'mH') {
		linkObj2.hover(
			function(){
					var xMarkObj = $(this).find('a'); 
					xMarkObj.css('width','27px');
					var xHidden = $(this).find('a.mmHide');
					xHidden.css('display' , 'block');
			},
			function () {
					$(this).find('a').css('width','90px');
					xHidden = $(this).find('a.mmHide');
					xHidden.css('display' , 'none');
			}
		);
		}
		
		var linkObj = $('.owBlock li a');
		/* ховер выбора оценок */
		linkObj.hover(function() {
			if( xTest === true) {
				var xClass = $(this).parent().attr('title');
				var xText = $(this).attr('title');
				var xWindMarkVal = $(this).text();
					obj.text(xText);
				
				/* эвент для запуска */
				$(this).click(function(){
					if (xText == oldMark) {
						if (oldMark == '<span>x</span>') {obj.html(oldMark);obj.removeAttr('class').addClass('mmPlace');}
						else {obj.html(oldMark);}
						boxerInplace2.hide();
						return false;
					} else {
					obj.removeAttr('class').addClass(xClass);
					obj.empty().addClass('ajaxWait2');
					if( xTest == true) {
						xTest = false;
						myAjax.send({
						pid: Pid,
						type : 'mark',
						value : xText,
						succcess : function(){
							obj.empty().removeClass('ajaxWait2');
							obj.text(xText);
						},
						error : function(){
							obj.removeClass('ajaxWait2');
							if (oldMark == '<span>x</span>') {obj.html(oldMark);obj.removeAttr('class').addClass('mmPlace');}
							else {obj.html(oldMark);}
							boxerInplace2.show(obj,
								'<div style="padding:10px; width:160px; text-align:center">Произошел сбой.<br />Попробуйте ещё раз</div>',
								{delay : 2000 ,className : "confirm2", xId:'boxerInplace2'}
							);
						}
					})
					}
					boxerInplace2.hide();
					return false;
				}
				})
			}
		},
		function(){
			if( xTest === true) {
				obj.html(oldMark);
		}});
		/* эвент для удаления отметки */
		$('div .mmDelet').click(function() {
			if (oldMark == '<span>x</span>') {
				obj.html('<span>x</span>');
				obj.removeAttr('class').addClass('mmPlace');
			} else {
				obj.empty().addClass('ajaxWait2');
				if( xTest == true) {
				xTest = false;
				myAjax.send({
					pid: Pid,
					type : 'mark',
					value : 'delet',
					succcess : function(){
						obj.html('<span>x</span>').removeAttr('class').addClass('mmPlace');
					},
					error : function(){
						obj.removeClass('ajaxWait2');
						if (oldMark == '<span>x</span>') {obj.html(oldMark);obj.removeAttr('class').addClass('mmPlace');}
						else {obj.html(oldMark);}
						boxerInplace2.show(obj,
							'<div style="padding:10px; width:160px; text-align:center">Произошел сбой.<br />Попробуйте ещё раз</div>',
							{delay : 2000 ,className : "confirm2", xId:'boxerInplace2'}
						);
					}
				});
				}
			}
			boxerInplace2.hide();
			return false;
		});
		return false;
	});
	
});
	



/***************************************************
	My AJAX
****************************************************/
(function($){ myAjax = {
	Options : {
		timeout: 10000,
		simpleAjax: false,
		urlDispos: false,
		url: 'ajax.php'
	},
	
	send : function(options) {
		this.options = {};
		$.extend( this.options, this.Options, options );
		myAjax.Options = this.options;
//		myAjax.Options.urlDispos = false? url=this.options.url : url=myAjax.Options.url;
		myOverlay.show();
		$.ajax({
			timeout : myAjax.Options.timeout,
			type : "POST",
			url : this.options.url,
			dataType : "json",
//			ifModified : true,
			data: {'lessonID':lessonID, 'Pid':this.options.pid , 'type':this.options.type, 'value':this.options.value},
			success : function (data) {
				myOverlay.hide();
				myAjax.Options.succcess();
			},
			error : function () {
				myOverlay.hide();
				myAjax.Options.error();
			}
		});	
	},
	
	response : function() {
		$('.test1').fadeOut(1000, function(){alert('OK');});
	}
};
})(jQuery);




/****************************************************
	MyOverlay
*****************************************************/
(function($){ myOverlay = {
	options : {
		zIndex : 1000,
		overlayId : 'overlay',
		destroy : true
	},
	show : function () {
		options = myOverlay.options;
		if (options.destroy == false && this.inited == true) {
			$("#"+overlayId).show();
		} else {
			$('body').append('<div id="'+options.overlayId+'" style="z-index:'+options.zIndex+';"></div>');
		}
		this.inited = true;
	},
	hide : function () {
		if (options.destroy == false) {
			$('#'+options.overlayId).hide();
		} else {
			$('#'+options.overlayId).remove();
			this.inited = false;
		}
	}
}
})(jQuery);




/***************************************************************
	boxerHelper
****************************************************************/
(function($) {
boxerHelper = {
	nativeOptions : {
		buttons : [],
		delay : 2000
	},
	show: function (element, text,  options ) {
		var element = ( typeof(element) == "object" ) ? ( typeof(element.jquery) == "undefined" ? element : element.get(0) ) : $(element)[0];
		this.element = element;
		this.options = {};
		$.extend( this.options, this.nativeOptions, options );
		var params = this.elementParams( element );
		
		this.zId = (this.options.xId != '') ? this.options.xId : 'helper';
		this.zTop = (this.options.xTop != '') ? this.options.xTop : '0';
		
		this.init(); /* INIT */
		this.html.text.html( text );
		this.html.css( {
			left: params.p[0] + params.d[1] + 20, /* gorysont */
			top: params.p[1] - this.zTop /* vertical*/
		});
		this.html[0].className = this.options.className || "";
		if (this.timeToClose) { clearTimeout(this.timeToClose); };
		this.html.hide().fadeIn(200);
		if (this.options.delay) { this.timeToClose = setTimeout( function () { boxerInplace.hide(); }, this.options.delay ); };
		
	},
	hide: function () {
		this.html.fadeOut(1 , function(){ $(this).remove(); });
		this.inited = false;
	},
	init: function () {
		if (this.inited) { return false; };
		
		this.html = $('<div id="'+ this.zId +'"><p class="text"></p><div><hr/></div></div>')
			.appendTo($("body")).hide();
		this.html.text = this.html.find(".text");
		
		this.inited = true;
	},
	elementParams: function ( element ) {
		var left = 0;
		var top = 0;
		var width = element.offsetWidth;
		var height = element.offsetHeight;
		if (element.offsetParent) {
			do {
					left += element.offsetLeft;
					top += element.offsetTop;
			} while (element = element.offsetParent);
		};
		
		/* -redacted- */
		var A;
		if(self.innerWidth!=undefined) { A= [self.innerWidth,self.innerHeight];	} else {
			var D= document.documentElement;
			if(D) {A= [D.clientWidth,D.clientHeight];}
		}
		if (Math.round(A[0]) < 1190) { left = left-(left-Math.round(A[0])+200);}
		return {
			d: [width, height],
			p: [left, top]
		};
	}
};
})(jQuery);




/******************************************* 
	im.boxerInplace2
*******************************************/
(function($) {
boxerInplace2 = {
	nativeOptions : {
		buttons : [],
		delay : 2000
	},
	show: function (element, text,  options ) {
		var element = ( typeof(element) == "object" ) ? ( typeof(element.jquery) == "undefined" ? element : element.get(0) ) : $(element)[0];
		this.element = element;
		this.options = {};
		$.extend( this.options, this.nativeOptions, options );
		var params = this.elementParams( element );
		
		this.zId = (this.options.xId != '') ? this.options.xId : 'boxerInplace';
		
		this.init(); // вызов INIT
		this.html.text.html( text ); // подставляем текст
		
		/* кнопачки */
		this.html.buttons.html("").hide();
		if(this.options.buttons.length) { this.html.buttons.show(); }
		$.each(this.options.buttons, function () {
			$('<a href="#" title="' + this.text + '">' + this.text + '</a>').appendTo(boxerInplace2.html.buttons).click( function () {
				boxerInplace2.hide();
				this.callback.apply( boxerInplace2.element );
				return false;
			})[1].callback = this.callback || function () {} ;
		});
		
		this.html.css( {
			left: params.p[0],
			top: params.p[1] + params.d[1] + 5
		});
		this.html[0].className = this.options.className || ""; // делаем классно
		if (this.timeToClose) { clearTimeout(this.timeToClose); };
		this.html.hide().fadeIn(200);
		if (this.options.delay) { this.timeToClose = setTimeout( function () { boxerInplace2.hide(); }, this.options.delay ); };
		
		/*this.overlay.click(function() {
			this.overlay.hide();
			this.html.hide();
		});*/
		
	},
	hide: function () {
		//this.html.fadeOut(200);
		this.html.fadeOut(200 , function(){ $(this).remove(); });
		this.inited = false;
	},
	init: function () {
		if (this.inited) { return false; };
		
		this.html = $('<div id="'+ this.zId +'"><div class="text"></div><div class="btns"></div></div>')
			.appendTo($("body")).hide();
//		this.html = $('<div id="boxerInplace2"><div class="text"></div><div class="btns"></div></div>').appendTo($("body")).hide();
		this.html.text = this.html.find(".text");
		this.html.buttons = this.html.find(".btns");
		
		this.inited = true;
	},
	elementParams: function ( element ) {
		var left = 0;
		var top = 0;
		var width = element.offsetWidth;
		var height = element.offsetHeight;
		if (element.offsetParent) {
			do {
					left += element.offsetLeft;
					top += element.offsetTop;
			} while (element = element.offsetParent);
		};
		
		var A;
		if(self.innerWidth!=undefined) { A= [self.innerWidth,self.innerHeight];	}
		else {
			var D= document.documentElement;
			if(D) {A= [D.clientWidth,D.clientHeight];}
		}
		if (Math.round(A[0]) < 1190) { left = left-(left-Math.round(A[0])+200);}
		return {
			d: [width, height],
			p: [left, top]
		};
	}
};

window.boxerInplaceMessage = function(element, text, delay) {
	boxerInplace2.show( element, text, { delay : delay } );
};

window.boxerInplaceError = function(element, text, delay) {
	boxerInplace2.show( element, text, { className : "error", delay : delay } );
};

window.boxerInplaceConfirm = function( element, text, yescallback, nocallback, yestext, notext ) {
	boxerInplace2.show( element, text, { 
		buttons: [
			{ text : yestext || "Да",
			  callback : yescallback
			},
			{ text : notext || "Нет",
			  callback : nocallback
			}
		],
		delay : false,
		className : "confirm"
	});
};

$.fn.boxerInplaceMessage = function(text, delay) {
	return this.each ( function () {
		$(this).click( function () {
			boxerInplaceMessage(this, this.boxerInplace2.text, this.boxerInplace2.delay);
			return false;
		});
		this.boxerInplace2 = {
			text : text,
			delay : delay
		};
	});
};

$.fn.boxerInplaceError = function(text, delay) {
	return this.each ( function () {
		$(this).click( function () {
			boxerInplaceError(this, this.boxerInplace2.text, this.boxerInplace2.delay);
			return false;
		});
		this.boxerInplace2 = {
			text : text,
			delay : delay
		};
	});
};

$.fn.boxerInplaceConfirm = function(text, yescallback, nocallback, yestext, notext) {
	return this.each ( function () {
		$(this).click( function () {
			boxerInplaceConfirm(this, this.boxerInplace2.text, this.boxerInplace2.yescallback, this.boxerInplace2.nocallback, this.boxerInplace2.yestext, this.boxerInplace2.notext);
			return false;			
		});
		if ( ( typeof(yescallback) == "undefined" ) && ( typeof(this.href) != "undefined" ) ) { 
			yescallback = function () {
				window.location = this.href;
			};
		};		
		this.boxerInplace = {
			text : text,
			yescallback : yescallback, 
			nocallback : nocallback,
			yestext : yestext, 
			notext : notext
		};
	});
};
})(jQuery);




/****************************************************
	переход по Key
******************************************************/
$(function() {
//	$('td input').focus(function() {
		
		$('td input').keypress(function(e){
			xThis = $(this);
			xFocus = null;
			var len = $('tbody tr').length; // удалить
			var xInpId = xThis.attr('id');
			log.debug('xInpId- '+xInpId);
			var xInputStringId = xInpId.split('-');
			a = parseInt(xInputStringId[0]);
			b = parseInt(xInputStringId[1]);
			log.info('a= '+ a+ ' b= '+ b);
			
			// ENTER
			if (e.keyCode == 13){
				if (a <= len) {
					a = a+1;
					xFocus = document.getElementById(a + '-' + b);
				} else {
					b = b + 1;
					xFocus = document.getElementById(0 + '-' + b);
				}
			}
			/*else if (e.keyCode == 37){
				var xInpId = xThis.attr('id');
				var xInputStringId = xInpId.split('-');
				xInputStringId[1] = parseInt(xInputStringId[1])-1
				var xFocus = document.getElementById(xInputStringId[0] + '-' + xInputStringId[1]);
				//log.info(xInputStringId[1]);
				if (xFocus == null) {
					xInputStringId[0] = parseInt(xInputStringId[0])-1;
					xFocus = document.getElementById(xInputStringId[0] + '-' + '5');
				}
//				xFocus.focus();
			}
			else if (e.keyCode == 39){
				var xInpId = xThis.attr('id');
				var xInputStringId = xInpId.split('-');
				xInputStringId[1] = parseInt(xInputStringId[1])+1
				var xFocus = document.getElementById(xInputStringId[0] + '-' + xInputStringId[1]);
				if (xFocus == null) {
					aaa = parseInt(xInputStringId[0]);
					ddd = aaa + 1;
//					alert(ddd);
					xFocus = document.getElementById(ddd + '-' + '1');
//					log.info(xInputStringId[0]);
				}
//				xFocus.focus();
			}*/
			e = null;
			xInputStringId = null;
			xThis = 'fdsf';
			a = null;
			b = null;
			xFocus.focus();
			log.debug('a= '+ a+ ' b= '+ b);
		});
//	});
});

